<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>职位管理</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="Hosting Store Responsive web template, Bootstrap Web Templates, Flat Web Templates, Andriod Compatible web template,
Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyErricsson, Motorola web design" />
    <script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>

    <%--<link href="${pageContext.request.contextPath}/static/admin/assets/css/minimal.css" rel="stylesheet"/>--%>
    <link href="${pageContext.request.contextPath}/static/home/css/bootstrap.css" rel='stylesheet' type='text/css' />

    <script src="${pageContext.request.contextPath}/static/home/js/jquery-1.11.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/admin/assets/js/vendor/bootstrap/bootstrap.min.js"></script>
    <!-- Custom Theme files -->
    <link href="${pageContext.request.contextPath}/static/home/css/style.css" rel='stylesheet' type='text/css' />
    <!-- Custom Theme files -->

    <!-- webfonts -->
    <link href='${pageContext.request.contextPath}/static/home/css/font-awesome.css' rel='stylesheet' type='text/css'/>
    <!-- webfonts -->
    <!-- dropdown -->
    <script src="${pageContext.request.contextPath}/static/home/js/jquery.easydropdown.js"></script>
    <script src="${pageContext.request.contextPath}/static/home/js/jquery-labelauty.js"></script>

    <link href="${pageContext.request.contextPath}/static/home/css/nav.css" rel="stylesheet" type="text/css" media="all"/>
    <link href="${pageContext.request.contextPath}/static/home/css/jquery-labelauty.css" rel='stylesheet' type='text/css' />
    <link href="${pageContext.request.contextPath}/static/admin/css/sweetalert.css" rel="stylesheet">

    <link href="${pageContext.request.contextPath}/static/home/css/new_jobs.css" rel='stylesheet' type='text/css' />
    <link href="${pageContext.request.contextPath}/static/home/css/daterangepicker-bs3.css" rel='stylesheet' type='text/css' />
    <link href="${pageContext.request.contextPath}/static/home/css/daterangepicker-1.3.7.css" rel='stylesheet' type='text/css' />
    <!-- start-smoth-scrolling -->
    <script src="${pageContext.request.contextPath}/static/admin/js/sweetalert.min.js"></script>
    <!-- start-smoth-scrolling -->
    <!-- webfonts -->
    <%--<link href='http://fonts.useso.com/css?family=Ubuntu:300,400,500,700' rel='stylesheet' type='text/css'>--%>
    <!-- webfonts -->
    <!-- start-smoth-scrolling -->
    <link href="${pageContext.request.contextPath}/static/admin/assets/css/vendor/bootstrap/bootstrap.min.css" rel="stylesheet"/>

    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/home/css/bootstrap-checkbox.css">
    <link href="${pageContext.request.contextPath}/static/home/css/job_management_table.css" rel="stylesheet">
    <style>
        .col-md-3 {
            width: 20% !important;
        }

        .bg-transparent-white-2 {
            background-color: rgba(255, 255, 255, 0.2) !important;
            color: #000;
        }
    </style>
</head>
<!-- Header Starts Here -->
<div class="banner inner-banner" >
    <%@include file="../header.jsp"%>

    <div id="breadcrumb_wrapper">
        <div class="container">

            <h3><strong>职位列表管理</strong></h3>
            <h6>&nbsp;</h6>

            <div class="clearfix"></div>
        </div>
    </div>
</div>
<div class="clearfix"> </div>
<!-- Header Ends Here -->

<!--Main Starts Here-->
<div class="domain-section">
    <div class="about_grid">
        <div class="container">
            <div class="wow fadeInRight" data-wow-delay="0.4s" style="margin-bottom: 2%">

                <div class="col-md-2">
                    <input type="text" id="job_name" style="margin-top: -1%">
                </div>

                <div class="col-md-1">
                    <input type="button" value="搜索" style="margin-top: -4%" onclick="fetchData()">
                </div>

                <div class="col-md-8">
                    <a href="${pageContext.request.contextPath}/home/job/create.action" style="float: right">
                        <input type="button" value="发布新职业" style="margin-top: -2%;"></a>
                </div>

                <div class="col-md-1">
                    <input type="button" value="删除" style="margin-top: -4%;" onclick="delete_confirm()">
                </div>

            </div>
            <br>
            <input type="hidden" id="select_num" value="1">
            <div class="main-table">
                <ul class="nav nav-tabs nav-table" role="tablist">
                    <li role="presentation" class="active"><a href="#releasing" aria-controls="releasing" role="tab" data-toggle="tab">发布中职位</a></li>
                    <li role="presentation"><a href="#unreleased" aria-controls="unreleased" role="tab" data-toggle="tab">未发布职位</a></li>
                    <li role="presentation"><a href="#released" aria-controls="released" role="tab" data-toggle="tab">发布结束职位</a></li>
                    <li role="presentation"><a href="#confirming" aria-controls="confirming" role="tab" data-toggle="tab">审核中职位</a></li>
                    <li role="presentation"><a href="#fail" aria-controls="fail" role="tab" data-toggle="tab">未通过职位</a></li>
                </ul>
                <div class="tab-content">
                    <div role="tabpanel" class="tab-pane fade in active" id="releasing">
                        <section class="tile">
                            <!-- tile header -->
                            <!-- /tile header -->

                            <!-- tile body -->
                            <div class="tile-body nopadding">

                                <table class="table table-bordered">
                                    <thead>
                                    <tr>
                                        <th style="width: 40px;">
                                            <div class="checkbox check-transparent">
                                                <input type="checkbox" value="1" id="allchck1">
                                                <label for="allchck1"></label>
                                            </div>
                                        </th>
                                        <th>职位名称</th>
                                        <th>发布日期</th>
                                        <th>截止日期</th>
                                        <th>学历要求</th>
                                        <th>发布地点</th>
                                        <th>投递简历</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>

                                    </tbody>
                                </table>

                            </div>
                            <!-- /tile body -->
                            <div class="tile-footer bg-transparent-white-2 rounded-bottom-corners">
                                <div class="row">

                                    <div class="col-sm-offset-4 col-sm-4 text-center">
                                        <small class="inline table-options paging-info"></small>
                                    </div>

                                    <div class="col-sm-4 text-right sm-center">
                                        <ul class="pagination pagination-xs nomargin pagination-custom">

                                        </ul>
                                    </div>

                                </div>
                            </div>
                        </section>
                    </div>

                    <div role="tabpanel" class="tab-pane fade" id="unreleased">
                        <section class="tile">



                            <!-- tile header -->
                            <!-- /tile header -->

                            <!-- tile body -->
                            <div class="tile-body nopadding">

                                <table class="table table-bordered">
                                    <thead>
                                    <tr>
                                        <th style="width: 40px;">
                                            <div class="checkbox check-transparent">
                                                <input type="checkbox" value="1" id="allchck3">
                                                <label for="allchck3"></label>
                                            </div>
                                        </th>
                                        <th>职位名称</th>
                                        <th>发布日期</th>
                                        <th>截止日期</th>
                                        <th>学历要求</th>
                                        <th>发布地点</th>
                                        <th>投递简历</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>

                                    </tbody>
                                </table>

                            </div>
                            <!-- /tile body -->
                            <div class="tile-footer bg-transparent-white-2 rounded-bottom-corners">
                                <div class="row">

                                    <div class="col-sm-offset-4 col-sm-4 text-center">
                                        <small class="inline table-options paging-info"></small>
                                    </div>

                                    <div class="col-sm-4 text-right sm-center">
                                        <ul class="pagination pagination-xs nomargin pagination-custom">

                                        </ul>
                                    </div>

                                </div>
                            </div>
                        </section>
                    </div>

                    <div role="tabpanel" class="tab-pane fade" id="released">
                        <section class="tile">
                            <!-- tile header -->
                            <!-- /tile header -->

                            <!-- tile body -->
                            <div class="tile-body nopadding">

                                <table class="table table-bordered">
                                    <thead>
                                    <tr>
                                        <th style="width: 40px;">
                                            <div class="checkbox check-transparent">
                                                <input type="checkbox" value="1" id="allchck4">
                                                <label for="allchck4"></label>
                                            </div>
                                        </th>
                                        <th>职位名称</th>
                                        <th>发布日期</th>
                                        <th>截止日期</th>
                                        <th>学历要求</th>
                                        <th>发布地点</th>
                                        <th>投递简历</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr>
                                        <td>
                                            <div class="checkbox check-transparent">
                                                <input type="checkbox" value="1" id="chck04">
                                                <label for="chck04"></label>
                                            </div>
                                        </td>
                                        <td>打杂</td>
                                        <td>2016-08-03</td>
                                        <td>2016-08-04</td>
                                        <td>傻逼东软</td>
                                        <td>广州</td>
                                        <td>3</td>
                                        <td>暂无</td>
                                    </tr>
                                    </tbody>
                                </table>

                            </div>
                            <!-- /tile body -->
                            <div class="tile-footer bg-transparent-white-2 rounded-bottom-corners">
                                <div class="row">

                                    <div class="col-sm-offset-4 col-sm-4 text-center">
                                        <small class="inline table-options paging-info">showing 1-3 of 24 items</small>
                                    </div>

                                    <div class="col-sm-4 text-right sm-center">
                                        <ul class="pagination pagination-xs nomargin pagination-custom">
                                            <li class="disabled"><a href="#"><i class="fa fa-angle-double-left"></i></a></li>
                                            <li class="active"><a href="#">1</a></li>
                                            <li><a href="#">2</a></li>
                                            <li><a href="#">3</a></li>
                                            <li><a href="#">4</a></li>
                                            <li><a href="#">5</a></li>
                                            <li><a href="#"><i class="fa fa-angle-double-right"></i></a></li>
                                        </ul>
                                    </div>

                                </div>
                            </div>
                        </section>
                    </div>

                    <div role="tabpanel" class="tab-pane fade" id="confirming">
                        <section class="tile">



                            <!-- tile header -->
                            <!-- /tile header -->

                            <!-- tile body -->
                            <div class="tile-body nopadding">

                                <table class="table table-bordered">
                                    <thead>
                                    <tr>
                                        <th style="width: 40px;">
                                            <div class="checkbox check-transparent">
                                                <input type="checkbox" value="1" id="allchck5">
                                                <label for="allchck5"></label>
                                            </div>
                                        </th>
                                        <th>职位名称</th>
                                        <th>发布日期</th>
                                        <th>截止日期</th>
                                        <th>学历要求</th>
                                        <th>发布地点</th>
                                        <th>投递简历</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr>
                                        <td>
                                            <div class="checkbox check-transparent">
                                                <input type="checkbox" value="1" id="chck05">
                                                <label for="chck05"></label>
                                            </div>
                                        </td>
                                        <td>打杂</td>
                                        <td>2016-08-03</td>
                                        <td>2016-08-04</td>
                                        <td>傻逼东软</td>
                                        <td>广州</td>
                                        <td>4</td>
                                        <td>暂无</td>
                                    </tr>
                                    </tbody>
                                </table>

                            </div>
                            <!-- /tile body -->
                            <div class="tile-footer bg-transparent-white-2 rounded-bottom-corners">
                                <div class="row">

                                    <div class="col-sm-offset-4 col-sm-4 text-center">
                                        <small class="inline table-options paging-info">showing 1-3 of 24 items</small>
                                    </div>

                                    <div class="col-sm-4 text-right sm-center">
                                        <ul class="pagination pagination-xs nomargin pagination-custom">
                                            <li class="disabled"><a href="#"><i class="fa fa-angle-double-left"></i></a></li>
                                            <li class="active"><a href="#">1</a></li>
                                            <li><a href="#">2</a></li>
                                            <li><a href="#">3</a></li>
                                            <li><a href="#">4</a></li>
                                            <li><a href="#">5</a></li>
                                            <li><a href="#"><i class="fa fa-angle-double-right"></i></a></li>
                                        </ul>
                                    </div>

                                </div>
                            </div>
                        </section>
                    </div>

                    <div role="tabpanel" class="tab-pane fade" id="fail">
                        <section class="tile">



                            <!-- tile header -->
                            <!-- /tile header -->

                            <!-- tile body -->
                            <div class="tile-body nopadding">

                                <table class="table table-bordered">
                                    <thead>
                                    <tr>
                                        <th style="width: 40px;">
                                            <div class="checkbox check-transparent">
                                                <input type="checkbox" value="1" id="allchck6">
                                                <label for="allchck6"></label>
                                            </div>
                                        </th>
                                        <th>职位名称</th>
                                        <th>发布日期</th>
                                        <th>截止日期</th>
                                        <th>学历要求</th>
                                        <th>发布地点</th>
                                        <th>投递简历</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr>
                                        <td>
                                            <div class="checkbox check-transparent">
                                                <input type="checkbox" value="1" id="chck06">
                                                <label for="chck06"></label>
                                            </div>
                                        </td>
                                        <td>打杂</td>
                                        <td>2016-08-03</td>
                                        <td>2016-08-04</td>
                                        <td>傻逼东软</td>
                                        <td>广州</td>
                                        <td>5</td>
                                        <td>暂无</td>
                                    </tr>
                                    </tbody>
                                </table>

                            </div>
                            <!-- /tile body -->
                            <div class="tile-footer bg-transparent-white-2 rounded-bottom-corners">
                                <div class="row">

                                    <div class="col-sm-offset-4 col-sm-4 text-center">
                                        <small class="inline table-options paging-info">showing 1-3 of 24 items</small>
                                    </div>

                                    <div class="col-sm-4 text-right sm-center">
                                        <ul class="pagination pagination-xs nomargin pagination-custom">
                                            <li class="disabled"><a href="#"><i class="fa fa-angle-double-left"></i></a></li>
                                            <li class="active"><a href="#">1</a></li>
                                            <li><a href="#">2</a></li>
                                            <li><a href="#">3</a></li>
                                            <li><a href="#">4</a></li>
                                            <li><a href="#">5</a></li>
                                            <li><a href="#"><i class="fa fa-angle-double-right"></i></a></li>
                                        </ul>
                                    </div>

                                </div>
                            </div>
                        </section>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>
<!--Main Ends Here-->

<table id="table_td_temp" style="display:none">
    <tbody id="template-list-tbody">
    <tr>
        <td>
            <div class="checkbox check-transparent">
                <input type="checkbox" value="" id="">
                <label for=""></label>
            </div>
        </td>
        <td>打杂</td>
        <td>2016-08-03</td>
        <td>2016-08-04</td>
        <td>傻逼东软</td>
        <td>广州</td>
        <td>0</td>
        <td><a class="check-toggler delete">删除&nbsp;</a>
            <a href="" class="detail">查看详情&nbsp;</a>
            <a href="" class="edit">编辑&nbsp;</a>
        </td>
    </tr>
    </tbody>
</table>

<!-- #Footer -->
<%@include file="../footer.jsp"%>
<!-- /#Footer -->
<!-- here stars scrolling icon -->
<script type="text/javascript" src="${pageContext.request.contextPath}/static/home/js/move-top.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/home/js/easing.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/home/js/moment.min.js"></script>
<script src="${pageContext.request.contextPath}/static/admin/js/page.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/home/js/daterangepicker-1.3.7.js"></script>
<script type="text/javascript">
    jQuery(document).ready(function($) {
        $(".scroll").click(function(event){
            event.preventDefault();
            $('html,body').animate({scrollTop:$(this.hash).offset().top},1000);
        });
    });
</script>
<!-- /#Footer -->
<!-- here stars scrolling icon -->
<script type="text/javascript">
    $(document).ready(function() {
        /*
         var defaults = {
         containerID: 'toTop', // fading element id
         containerHoverID: 'toTopHover', // fading element hover id
         scrollSpeed: 1200,
         easingType: 'linear'
         };
         */

        $().UItoTop({ easingType: 'easeOutQuart' });

    });
</script>
<script>
    $(function(){
        //check all checkboxes
        $('table thead input[type="checkbox"]').change(function () {
            $(this).parents('table').find('tbody input[type="checkbox"]').prop('checked', $(this).prop('checked'));
        });
    })

</script>

<script>
    $('#myTabs a').click(function (e) {
        e.preventDefault();
        $(this).tab('show');
        console.log(this);
    });

    $('#myTabs a[href="#profile"]').tab('show') // Select tab by name
    $('#myTabs a:first').tab('show'); // Select first tab
    $('#myTabs a:last').tab('show'); // Select last tab
    $('#myTabs li:eq(2) a').tab('show'); // Select third tab (0-indexed)

    $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
        e.target // newly activated tab
        e.relatedTarget // previous active tab
        var str = e.target.href.toString();
        var s = str.substring(str.lastIndexOf('#'));
        console.log(s);
        if (s == "#releasing"){
            $('#select_num').val('1');
        }else if(s == "#unreleased") {
            $('#select_num').val('2');
        }else if(s == "#released") {
            $('#select_num').val(3);
        }else if(s == "#confirming") {
            $('#select_num').val(4);
        }else if(s == "#fail") {
            $('#select_num').val(5);
        }
        console.log($('#select_num').val());
        fetchData();
    });
</script>
<!-- //here ends scrolling icon -->

<script>
    var show = "";
    var fetchData = function (furl) {
        if(furl==null) {
            url = "${pageContext.request.contextPath}/home/job/getJobList.action?p=1";
        }else{
            url = furl;
        }
        var job_name = $('#job_name').val();
        var select_num = $('#select_num').val();
        var str = "#releasing";
        if (select_num == 1){
            str = "#releasing";
        }else if(select_num == 2) {
            str = "#unreleased";
        }else if(select_num == 3) {
            str = "#released";
        }else if(select_num == 4) {
            str = "#confirming";
        }else if(select_num == 5) {
            str = "#fail";
        }

        console.log(job_name);
        $.ajax({
            type:'get',
            url:url,
            data:'job_name='+job_name+'&select='+select_num,
            success:function(json){
                console.log(json);
                show = json.show;
                if (show=="" ||show.totalRows == 0) {
                    $(str +" table tbody").html('<tr><td colspan="10" align="center">暂无记录</td></tr>');
                    $(str + ' .paging-info').html("showing 0-0 of 0 items");
                    $(str + ' .pagination').html("");
                    return;
                } else {
                    var list = json.data;
                    var body = $(str +" table tbody");
                    var temp_body = $('#template-list-tbody');
                    var tds = $('#table_td_temp td');
                    var string = "";
                    for (var i in list) {
                        $("#table_td_temp input").val(list[i].job_id);
                        $("#table_td_temp input").attr("id", "chck" + list[i].job_id);
                        $("#table_td_temp label").attr("for", "chck" + list[i].job_id);
                        $("#table_td_temp .delete").attr("href","javascript:delete_confirm("+list[i].job_id+")");
                        $("#table_td_temp .detail").attr("href","${pageContext.request.contextPath}/home/job/detail.action?job_id="+list[i].job_id);
                        $("#table_td_temp .edit").attr("href","${pageContext.request.contextPath}/home/job/edit.action?job_id="+list[i].job_id);
                        tds[1].innerHTML = list[i].job_name;
                        tds[2].innerHTML = list[i].date_start_string;
                        tds[3].innerHTML = list[i].date_end_string;
                        tds[4].innerHTML = list[i].degree.degree_name;
                        tds[5].innerHTML = list[i].city.name;
                        tds[6].innerHTML = json.delivery_num[i];
                        string += temp_body.html();
                    }
                    body.html(string);
                    if(show.currentPage == show.totalPage){
                        $(str + ' .paging-info').html("showing "+(show.startIndex+1)+"-"+show.totalRows+" of "+show.totalRows+" items");
                    }else {
                        $(str + ' .paging-info').html("showing "+(show.startIndex+1)+"-"+show.endIndex+" of "+show.totalRows+" items");
                    }
                    make_page(show,str + ' .pagination','?');
                }
            }
        });
    };

    fetchData();

    function delete_confirm(id) {
        var ids = new Array();
        if (id == null) {
            var select_num = $('#select_num').val();
            var str = "#releasing";
            if (select_num == 1) {
                str = "#releasing";
            } else if (select_num == 2) {
                str = "#unreleased";
            } else if (select_num == 3) {
                str = "#released";
            } else if (select_num == 4) {
                str = "#confirming";
            } else if (select_num == 5) {
                str = "#fail";
            }
            var selected = $(str + ' tbody input:checkbox:checked');
            if (selected.length == 0) {
                swal("", "请选择要删除的职位！", "error");
                return;
            }
            for (var i = 0; i < selected.length; i++) {
                ids[i] = selected[i].value;
            }
        } else {
            ids[0] = id;
        }
        var ids_arr = {"ids": ids};
        swal({
            title: "",
            text: "确认删除？",
            type: "warning",
            showCancelButton: true,
            closeOnConfirm: true,
            confirmButtonText: "确定",
            confirmButtonColor: "#ec6c62"
        }, function () {
            deleteJobs(ids_arr);
        });
    }

    function deleteJobs(ids){
        $.ajax({
            url:"${pageContext.request.contextPath}/home/job/deleteJobs.action",
            type:'post',
            contentType:'application/json;charset=utf-8',
            data:JSON.stringify(ids),
            success:function(json){
                if(json != 1){
                    swal("", "删除错误！", "error");
                }else{
                    swal("", "删除成功！", "success");
                }
                if(show.totalRows!=0) {
                    fetchData("${pageContext.request.contextPath}/home/job/getJobList.action?p="+show.currentPage);
                }
                if($('table thead input[type="checkbox"]').prop('checked')){
                    $('table thead input[type="checkbox"]').prop('checked', false);
                }
            }
        });
    }
</script>
</body>
</html>
